package it.gameplanet.model;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.gwt.validation.client.NotEmpty;
import com.google.gwt.validation.client.NotNull;
import com.google.gwt.validation.client.interfaces.IValidatable;

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Categoria implements Serializable, IValidatable {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    @NotEmpty
    @NotNull
    private String nome;
    
    @Persistent
    private String parent;

    public Categoria() {
		super();
	}

	public Categoria(String nome, String parent) {
		super();
		this.nome = nome;
		this.parent = parent;
	}

	public long getId() {
		return id;
	}
	
	public void setId(long id) {
		this.id = id;
	}
	public String getNome() {
		return nome;
	}
	public void setNome(String serverInfo) {
		this.nome = serverInfo;
	}

	public String getParent() {
		return parent;
	}

	public void setParent(String parent) {
		this.parent = parent;
	}
	
	public String getCompositeFormat() {
		if(parent!=null) {
			return parent + " / " + nome;
		}
		else {
			return nome;
		}
	}
}
